package com.example.support.oss;

import java.io.File;
import java.io.InputStream;

import com.aliyun.oss.OSSClient;

public class AliOssClient {

	private OSSClient client;
	private AliOssProperties aliOssProperties;

	public AliOssClient(OSSClient client, AliOssProperties aliOssProperties) {
		this.client = client;
		this.aliOssProperties = aliOssProperties;
	}

	public String putObjectFile(String key, String filepath) {
		client.putObject(aliOssProperties.getBucketName(), key, new File(filepath));
		return aliOssProperties.getWeburl() + key;
	}

	public String putObjectStream(String key, InputStream input) {
		client.putObject(aliOssProperties.getBucketName(), key, input);
		return aliOssProperties.getWeburl() + key;
	}

	@Deprecated
	public String getImageWebUrl(String key) {
		return aliOssProperties.getWeburl() + key;
	}

}
